-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix the logo image in the "ui" UI example #7894
Fix the logo image in the "ui" UI example #7894
Conversation
Ping @ndarilek for review. |
Looks like the alt text remains in the current version of this PR? |
I do of course want the image back, but I'm not OK with removing the alt text.
I'd like to clarify that. Are you unsure what alt text is, unclear on its utility, or something else? Genuinely not trying to be sarcastic, but I'd rather fix this than remove accessibility, if only so our examples do a good job of it. |
I understand what alt text is but I haven't looked at the AccessKit pr before today and I don't understand the intent behind this implementation. With |
Got it. For context, I'm a blind screen reader user. When I explore this UI with NVDA (my screen reader) running, I can find the Bevy logo when reviewing screen content, and am told that it is the Bevy logo. Admittedly that isn't super useful in this toy example, but it does at least display what I'd like us to consider a best practice, and is useful for discussing screens and UIs in an inclusive way (I.e. someone saying "X is true on the screen with the Bevy logo" might not mean anything to me otherwise.) It's OK if the text isn't displayed--at least, it is until we've got a better UI that displays alt text similar to how HTML does. For the moment I needed some way to attach the alt text to an image, and making it a child node seemed to accomplish that. Ideally in the future we'll have a more fleshed-out UI component that includes alt text/widget descriptions directly and unambiguously. I can't of course speak to how this PR appears visually but I've verified that the UI example still presents alt text correctly. Apologies for breaking the image, and thanks for the fix! |
I've only been looking at the accessibility module for a few minutes so this might be nonsense, but would a change something like this be acceptable: #[derive(Component)]
pub struct AltText(pub String);
fn image_changed(
mut commands: Commands,
mut query: Query<
(Entity, &AltText, Option<&mut AccessibilityNode>),
(Changed<UiImage>, Without<Button>),
>,
) {
for (entity, alt_text, accessible) in &mut query {
let name = alt_text.0.clone().into_boxed_str();
if let Some(mut accessible) = accessible {
accessible.set_role(Role::Image);
accessible.set_name(name);
} else {
let mut node = NodeBuilder::new(Role::Image);
node.set_name(name);
commands
.entity(entity)
.insert(AccessibilityNode::from(node));
}
}
} And we would add the |
This sort of design makes sense to me: you should be able to read both explicit alt text and text from |
For the moment, I've constrained the Image to a fixed size so it will display correctly with the text as a child. |
I'm absolutely in favor of adding more accessibility-specific components and fields, but I'd like to be intentional about it as part of comprehensive UI overhauls rather than creating individual, separate components. I made that mistake by introducing a All that is to say, if we can fix this without introducing a new component, I'd be more in favor of that, particularly with a 0.10 release imminent. |
🎉 I've deliberately left out a full code example for now. This is a) almost certain to change by the time 0.11 comes b) is quite clunky c) requires some [trickery](bevyengine/bevy#7894) to get alt text displaying properly. I care a lot about making this better, so stay tuned.
Had some further thoughts about this:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You say
I've replaced the ImageBundle with a NodeBundle that has a white background color and a UiImage component, and added a comment explaining why. I think this is okay and allows for the example to be included in 0.10 if there isn't time to find another solution for alt-text. It provides a demonstration of how to spawn a UI node with an image and children without errors.
But I don't see a comment explaining it.
I assume it's because the text is white and therefor invisible on white background? Not too hot on that, what made you chose that over using Visibility::Hidden
?
I'm not sure what to happened to the comment, perhaps I forgot to add it to the commit. I'll fix it.
This PR was written before the change that added a default font and A |
…le` set to `Display::None` and a `Text` component containing the alt-text.
Could you add a "fixes #8805" in the PR description? |
Objective
The AccessKit PR removed the loading of the image logo from the UI example.
It also added some alt text with
TextStyle::default()
as a child of the logo image node.If you give an image node a child, then its size is no longer determined by the measurefunc that preserves its aspect ratio. Instead, its width and height are determined by the constraints set on the node and the size of the contents of the node. In this case, the image node is set to have a width of 500 with no constraints on its height. So it looks at its child node to determine what height it should take. Because the child has
TextStyle::default
it allocates no space for the text, the height of the image node is set to zero and the logo isn't drawn.Fixes #8805
Solution
Load the image, and set min_size and max_size constraints of 500 by 125 pixels.